﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Classes {
    import flash.geom.*;
    import Engine.Helpers.*;
    import Engine.*;

    public class BridgePart extends ParkingLot {

        private var bridgeParentLocation:String;
        protected var m_bridgeOwner:Bridge;

        public function BridgePart(_arg1:String=null){
            super(_arg1);
        }
        override public function loadObject(_arg1:Object):void{
            var _local4:Bridge;
            var _local5:Rectangle;
            super.loadObject(_arg1);
            var _local2:Array = Global.world.getObjectsByClass(Bridge);
            var _local3:Rectangle = new Rectangle(getPosition().x, getPosition().y, getSize().x, getSize().y);
            if (_local2.length){
                for each (_local4 in _local2) {
                    if ((_local4 is Bridge)){
                        _local5 = new Rectangle(_local4.getPosition().x, (_local4.getPosition().y - _local4.getItem().bridge.bridgeBoundary.y), _local4.getItem().bridge.bridgeBoundary.x, _local4.getItem().bridge.bridgeBoundary.y);
                        if (_local5.intersects(_local3)){
                            _local4.addBridgePart(this);
                            break;
                        };
                    };
                };
            };
        }
        override public function setPosition(_arg1:Number, _arg2:Number, _arg3:Number=0):void{
            var _local4:Number;
            var _local5:Number;
            var _local6:Vector3;
            var _local7:Number;
            var _local8:Number;
            super.setPosition(_arg1, _arg2, _arg3);
            if (m_decoration){
                _local4 = m_decoOffset.x;
                _local5 = m_decoOffset.y;
                _local6 = this.getSize().scale(0.5);
                _local4 = (_local4 - _local6.x);
                _local5 = (_local5 - _local6.y);
                switch (m_direction){
                    case Constants.DIRECTION_SW:
                        _local7 = _local4;
                        _local8 = _local5;
                        break;
                    case Constants.DIRECTION_SE:
                        _local7 = -(_local5);
                        _local8 = _local4;
                        break;
                    case Constants.DIRECTION_NW:
                        _local7 = _local5;
                        _local8 = -(_local4);
                        break;
                    case Constants.DIRECTION_NE:
                        _local7 = -(_local4);
                        _local8 = -(_local5);
                        break;
                };
                _local4 = (_local7 + _local6.x);
                _local5 = (_local8 + _local6.y);
                m_decoration.setPosition((_arg1 + _local4), (_arg2 + _local5), _arg3);
                m_decoration.conditionallyReattach(true);
            };
        }
        override public function rotate():void{
            super.rotate();
            if (m_decoration){
                m_decoration.rotate();
                this.setPosition(m_position.x, m_position.y, m_position.z);
            };
            Global.world.citySim.roadManager.updateAllRoadTiles();
            Global.world.citySim.roadManager.updateRoads(this);
        }
        override protected function updateAdjacent():void{
            var _local1:int;
            var _local2:int;
            var _local3:int;
            if (m_adjacentRoads != null){
                return;
            };
            initalUpdateAdjacentCalculations();
            for each (_local1 in m_adjacentStretch) {
                m_adjacentRoads[_local1] = null;
            };
            m_adjacentStretch = [];
            for each (_local1 in m_adjacentTight) {
                m_adjacentRoads[_local1] = null;
            };
            m_adjacentTight = [];
            _local2 = 0;
            while (_local2 < m_adjacentRoads.length) {
                _local3 = _local2;
                if ((((_local3 == LEFT)) || ((_local3 == RIGHT)))){
                    m_adjacentRoads[_local3] = null;
                    m_adjacentPartial.splice(_local2, 1);
                };
                _local2++;
            };
        }
        override protected function getCurrentImage():ItemImageInstance{
            var _local1:ItemImageInstance = m_item.getCachedImage(m_state, this, m_direction, m_statePhase);
            return (_local1);
        }
        public function get bridgeOwner():Bridge{
            return (this.m_bridgeOwner);
        }
        public function set bridgeOwner(_arg1:Bridge):void{
            this.m_bridgeOwner = _arg1;
        }
        override public function getToolTipHeader():String{
            return (ZLoc.t("Items", "bridge_standard_friendlyName"));
        }
        override public function getToolTipPosition():Vector3{
            if (this.bridgeOwner){
                return (this.bridgeOwner.getToolTipPosition());
            };
            return (super.getToolTipPosition());
        }
        override public function getToolTipScreenOffset():Vector2{
            var _local1:Bridge = this.bridgeOwner;
            if (_local1){
                return (_local1.getToolTipScreenOffset());
            };
            return (null);
        }
        override public function canBeDragged():Boolean{
            return (false);
        }
        override public function canBeRotated():Boolean{
            return (false);
        }
        override public function cornerShouldAdjust(_arg1:Road, _arg2:int):Boolean{
            return (false);
        }
        override public function isSellable():Boolean{
            return (false);
        }
        override public function shouldAdjust(_arg1:Road, _arg2:int):Boolean{
            return (false);
        }
        override public function prepareToDrop(_arg1:Vector3, _arg2:Vector2):Road{
            return (this);
        }
        override public function isPositionValid():Boolean{
            return (false);
        }

    }
}//package Classes 
